[BLKTAP] Remove unnecessary timeout from tapdisk select() call.
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Fri, 29 Sep 2006 10:16:52 +0000 (11:16 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Fri, 29 Sep 2006 10:16:52 +0000 (11:16 +0100)
tapdisk was using a 1msec select() timeout in its main event loop.  On
timeout, the loop does nothing except repeat, so the timeout achieves
nothing; worse, on a machine with HZ set to less than 1000, a msec
timeout returns immediately, sending tapdisk into a 100%-CPU-
utilisation loop.

Simply remove the timeout entirely; everything still works fine, and
much more efficiently when idle.

Signed-off-by: Stephen Tweedie <sct@redhat.com>
tools/blktap/drivers/tapdisk.c

index 3190a2b2190b2bdb5fb4a0e0f104fa0c9b60d121..7c88027eb39747057ff7abc6594f9c9b0bdcaa28 100644 (file)
@@ -271,7 +271,6 @@ static int read_msg(char *buf)
        int length, len, msglen, tap_fd, *io_fd;
        char *ptr, *path;
        image_t *img;
-       struct timeval timeout;
        msg_hdr_t *msg;
        msg_newdev_t *msg_dev;
        msg_pid_t *msg_pid;
@@ -579,8 +578,7 @@ int main(int argc, char *argv[])
 {
        int len, msglen, ret;
        char *p, *buf;
-       fd_set readfds, writefds;
-       struct timeval timeout;
+       fd_set readfds, writefds;       
        fd_list_entry_t *ptr;
        struct tap_disk *drv;
        struct td_state *s;
@@ -622,12 +620,9 @@ int main(int argc, char *argv[])
                /*Set all tap fds*/
                LOCAL_FD_SET(&readfds);
 
-               timeout.tv_sec = 0; 
-               timeout.tv_usec = 1000; 
-
                /*Wait for incoming messages*/
                ret = select(maxfds + 1, &readfds, (fd_set *) 0, 
-                            (fd_set *) 0, &timeout);
+                            (fd_set *) 0, NULL);
 
                if (ret > 0) 
                {